<?require 'nebulae/includes/startup.php';
require 'nebulae/includes/data_handler.php';
require 'nebulae/includes/tools.php';
if(Debug)
{
	$Debug_tstart = microtime(true);
	$Debug_mstart = memory_get_usage(TRUE);
	
}$registry->set ('site_path', site_path);
$registry->set ('home_path', '/'); //root path
$registry->set ('image_path', '/public/images/'); // image path

# Load template object
$template = new Template($registry);
$registry->set ('template', $template);

#Load Lingua Object
$lingua = new Lingua($registry);
$registry->set ('lingua', $lingua);

# Load router
$router = new Router($registry);
$registry->set ('router', $router);

#Load Cadeiras Object
$cadeiras = new Cadeiras($registry, 'cadeiras');
$registry->set ('cadeiras', $cadeiras);

$router->setPath (site_path . 'controllers');

session_start();

$users = new users($registry, 'utilizadores');
$registry->set ('users', $users);

$classificados = new classificados($registry, 'classificados');
$registry->set ('classificados', $classificados);

# Load router
$router->delegate();

if(Debug)
{
	define ('MYSQL_STATUS', mysql_stat());
	define ('MYSQL_CLIENT_INFO', mysql_get_client_info());
	define ('MYSQL_HOST_INFO', mysql_get_host_info());
	define ('MYSQL_PROTO_INFO', mysql_get_proto_info());
		
	$output = '';
	$res = mysql_query('SHOW STATUS');
	while($row = mysql_fetch_array($res, MYSQL_NUM))
	{
		$output .= $row[0] . ": ";
		$output .= $row[1] . "<br />";
	}
	define ('MYSQL_ADVANCED_STATUS', $output);
}

$registry['db']->kill_db();

if(Debug)
{
	require 'nebulae/includes/stats.php';
}
	
?>